/*初始化数据表格*/
function initTable() {
    var url=getBasePath()+'/mdm/dataChangeLog/getListData.json';
    var tableId="table_data";
    $("#"+tableId).dataTable().fnDestroy();
    json = {};
    json.showLineNuber = false;
    json.id = tableId;
    json.pagesize=2;
    json.url = url ;
    json.param = [
        {"name": "logId", "value": $.trim($("#logId").val())},
        {"name": "dataType", "value": $.trim($("#dataType").val())},
        {"name": "dataPk", "value": $.trim($("#dataPk").val())},
        {"name": "modifyTime", "value": $.trim($("#modifyTime").val())},
        {"name": "modifyType", "value": $.trim($("#modifyType").val())},
    ];
    json.columns = [
        {
            "mData": "dataChangeLogCode", "sWidth": "15%", "sClass": "text-center",
            "mRender": function (data, type, row) {
                if (data) {
                    var editStr="<a href=\"#\"  data-am-popover=\"{theme: 'primary sm', content:'修改', trigger: 'hover focus'}\" onclick='toEditDataChangeLog("+data+");'><i class=\"icon-edit\"></i></a>";
                    var delStr="<a href=\"#\" data-am-popover=\"{theme: 'primary sm', content:'删除', trigger: 'hover focus'}\"  data-am-modal=\"{target: '#del-confirm', closeViaDimmer: 0, width: 400}\" onclick='deleteDataChangeLog("+data+");'><i class=\"icon-bin\"></i></a>";

                    return editStr+delStr;
                }
            }
        },
        {"mData": "logId", "sClass": "text-center"},
        {"mData": "dataType", "sClass": "text-center"},
        {"mData": "dataPk", "sClass": "text-center"},
        {"mData": "modifyTime", "sClass": "text-center"},
        {"mData": "modifyType", "sClass": "text-center"},
    ];
    var oTable1 = TableManaged(json).init();
}
/*查询数据*/
function doQuery(){
    initTable();
}

/*重置查询条件*/
function resetQueryForm(){
	$("#logId").val('');
	$("#dataType").val('');
	$("#dataPk").val('');
	$("#modifyTime").val('');
	$("#modifyType").val('');
}

/*删除数据*/
function deleteArea(dataChangeLogCode){
    var _url=getBasePath()+'/mdm/dataChangeLog/delete.htm';
    $.Confirm('你确定要删除这条记录吗？','',function(){
        var dataChangeLog={};
        dataChangeLog.dataChangeLogCode=dataChangeLogCode;
        $.ajax({
            url:_url,
            type:'POST',
            dataType:'json',
            contentType:'application/json',
            data:JSON.stringify(dataChangeLog),
            success:function(data){
                if(data.status==200){
                    $.Success('删除成功',doQuery);
                }else{
                    var msg = data.message || "删除数据变更日志数据发生错误";
                    $.Error(msg,'',null);
                }
            }
        });
    });

}

/*跳转编辑数据页面*/
function toEditArea(dataChangeLogCode){
    var _url=getBasePath()+'/mdm/dataChangeLog/toEdit.htm?dataChangeLogCode='+dataChangeLogCode;
    location.href=_url;
}

/*编辑数据*/
function editArea(){
    $validator =$("#dataChangeLog_edit_form").validator('isFormValid');
    if(!$validator){
        return;
    }
    var _url=getBasePath()+'/mdm/dataChangeLog/edit.htm';
    var dataChangeLog={};
	dataChangeLog.logId=$("#logId").val();
	dataChangeLog.dataType=$("#dataType").val();
	dataChangeLog.dataPk=$("#dataPk").val();
	dataChangeLog.modifyTime=$("#modifyTime").val();
	dataChangeLog.modifyType=$("#modifyType").val();

    $.ajax({
        url:_url,
        type:'POST',
        dataType:'json',
        contentType:'application/json',
        data:JSON.stringify(dataChangeLog),
        success:function(data){
            if(data.status==200){
                $.Success('该记录已提交成功!',gotoListPage);
            }else{
                var msg = data.message || "编辑数据变更日志数据发生错误";
                $.Error(msg,'',null);
            }

        },
        error:function(data){
            JSON.stringify(data);
        }
    });
}

/*跳转新增数据页面*/
function toAddArea(){
    var _url=getBasePath()+'/mdm/dataChangeLog/toAdd.htm';
    location.href=_url;
}

/*新增数据*/
function saveArea(){
    $validator =$("#dataChangeLog_add_form").validator('isFormValid');
    if(!$validator){
        return;
    }
    var _url=getBasePath()+'/mdm/dataChangeLog/add.htm';
    var dataChangeLog={};
	dataChangeLog.logId=$("#logId").val();
	dataChangeLog.dataType=$("#dataType").val();
	dataChangeLog.dataPk=$("#dataPk").val();
	dataChangeLog.modifyTime=$("#modifyTime").val();
	dataChangeLog.modifyType=$("#modifyType").val();
    
    $.ajax({
        url:_url,
        type:'POST',
        dataType:'json',
        contentType:'application/json',
        data:JSON.stringify(dataChangeLog),
        success:function(data){
            if(data.status==200){
                $.Success('该记录已提交成功!',gotoListPage);
            }else{
                var msg = data.message || "新增数据变更日志数据发生错误";
                $.Error(msg,'',null);
            }
        }
    });
}

/*跳转数据列表页面*/
function gotoListPage(){
    location.href=getBasePath()+'/mdm/dataChangeLog/list.htm';
}





